package com.vf.admin.client.dao;

import com.vf.admin.common.db.BaseDao;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.AppUserDongtai;
import com.vf.admin.miaodong.entity.AppUserLaHei;
import com.vf.admin.utils.StringEx;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author anxiang
 * @version 1.0.0
 * @ClassName AppUserDongtaiDao.java
 * @Description TODO
 */
@Repository
public class AppUserDongtaiDao extends BaseDao<AppUserLaHei> {

    public void saveOrUpdate(AppUserDongtai pojo) {
        if (pojo.getId() == null || pojo.getId() == 0) {
            pojo.setId(this.add(pojo));
        } else {
            this.update(pojo);
        }
    }

    public List<AppUserDongtai> findList(Integer userid) {
        List<Object> list = new ArrayList<>();
        StringBuilder str = new StringBuilder("");
        str.append("select * from app_user_dongtai where 1=1 ");
        if (StringEx.isNotNull(userid)) {
            str.append(" and userid = ? ");
            list.add(userid);
        }
        String sql = str.toString();
        return this.queryList(sql, list, AppUserDongtai.class, null);
    }

    public AppUserDongtai getByUseridAndGbUserid(Integer userid, Integer lhuserid) {
        List<Object> list = new ArrayList<>();
        StringBuilder str = new StringBuilder("");
        str.append("select * from app_user_dongtai where userid = ? and gbuserid = ? ");
        list.add(userid);
        list.add(lhuserid);
        String sql = str.toString();
        return this.queryObj(sql, list, AppUserDongtai.class);
    }

    public void delete(Integer id) {
        ArrayList<Object> list = new ArrayList<>();
        StringBuilder str = new StringBuilder("");
        str.append("delete from app_user_dongtai where id = ? ");
        list.add(id);
        String sql = str.toString();
        this.del(sql, list);
    }

}